import 'virtual:uno.css';
import { getRedirectUrl } from '@/tools/login-redirect.ts';
import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn';
import { get as getCookie } from 'es-cookie';
import { createPinia } from 'pinia';
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import { createApp } from 'vue';
// import 'ant-design-vue/dist/reset.css';
import App from './App.vue';
import router from './route/index.ts';
import './style.less';

dayjs.locale('en');

router.beforeEach((to, _, next) => {
	if (!getCookie('token') && to.path !== '/login') {
		// 未登录跳转登录页
		next(getRedirectUrl());
		return false
	}
	next();
});

const app = createApp(App as any);
const pinia = createPinia();
pinia.use(piniaPluginPersistedstate);
app.use(pinia);

app.use(router);
app.mount('#app');
